package com.tavio.vaultboy.util.vector;

public class Vector {
	public float x;
	
	public float y;
	
	public Vector(float x, float y) {
		this.x = x;
		this.y = y;
	}

	public Vector normalize() {
		float newX, newY;
		float norm = (float)Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));
		newX = x/norm;
		newY = y/norm;
		return new Vector(newX, newY);
	}
	
	public Vector add(Vector v) {
		return new Vector(x + v.x, y + v.y);
	}
	
	public Vector subtract(Vector v) {
		return new Vector(x - v.x, y - v.y);
	}
	
	public Vector multiply(float factor) {
		return new Vector(factor * x, factor * y);
	}
}
